<template>
  <!-- 点之间路径查询 -->
  <a-popover
    :overlay-style="{ width: '108px' }"
    :overlay-class-name="'switch-box-lasso-select'"
    placement="bottom"
    trigger="click"
    @visibleChange="visibleChange"
  >
    <div slot="content" class="batch-select-section">
      <div
        class="batch-select-tool"
        :class="{ 'item-active': boxSelectionEnable }"
        @click="selectMode(1)"
      >
        <a-icon-font type="icontaosuo1" />
        <span class="select-tool-text">矩形选框</span>
      </div>
      <div
        class="batch-select-tool"
        :class="{ 'item-active': lassoEnable }"
        @click="selectMode(2)"
      >
        <a-icon-font type="icontaosuo2" />
        <span class="select-tool-text">套索工具</span>
      </div>
    </div>
    <a-tooltip placement="top">
      <span slot="title">框选/套索</span>
      <span class="graph-analysis-btn batch-select-section-tag">
        <a-icon-font
          :class="{ active: lassoEnable || boxSelectionEnable }"
          :type="boxOrLasso === 1 ? 'icontaosuo1' : 'icontaosuo2'"
        />
        <span
          class="r-angle-right-down"
          :class="{ 'angle-right-active': lassoEnable || boxSelectionEnable }"
        ></span>
      </span>
    </a-tooltip>
  </a-popover>
</template>

<script lang="ts">
/**
 * 点之间的路径查询 两点 / 多点  气泡卡片
 */
import { Component, Vue, Prop } from 'vue-property-decorator'

@Component({})
export default class BoxChooseLassoPopover extends Vue {
  @Prop({ type: Number, default: 1 }) boxOrLasso?: number // 选择的方式
  @Prop({ type: Boolean, default: false }) lassoEnable: boolean = false // 套索开关
  @Prop({ type: Boolean, default: false }) boxSelectionEnable: boolean = false // 框选开关
  @Prop({ type: Boolean, default: false }) show: boolean = false

  public visibleChange(visible: boolean) {
    if (visible && (this.lassoEnable || this.boxSelectionEnable)) {
      this.$emit('select-mode', 4) // 关闭所有
    }
  }

  public selectMode(mode: boolean) {
    this.$emit('select-mode', mode)
  }
}
</script>

<style scoped lang="less">
.graph-analysis-btn {
  align-items: center;
  border-radius: 2px;
  color: #5d637e;
  cursor: pointer;
  display: flex;
  font-size: 16px;
  margin: 0 4px;
  padding: 4px;
  position: relative;

  &:hover {
    background-color: rgba(103, 113, 252, 0.1);
  }
}

// 框选 套索 小三角
.batch-select-section-tag {
  .r-angle-right-down {
    border-right: 4px solid #5d637e;
    border-top: 4px solid transparent;
    bottom: 0;
    height: 0;
    position: absolute;
    right: 0;
    width: 0;
  }

  .angle-right-active {
    border-right: 4px solid #6973ff;
  }
}

// 框选 套索
.batch-select-section {
  .batch-select-tool {
    cursor: pointer;
    height: 24px;
    line-height: 24px;
    padding-left: 18px;
    padding-right: 8px;
    width: 100%;

    &:hover {
      background-color: rgba(103, 113, 252, 0.2);
    }

    .select-tool-text {
      display: inline-block;
      padding-left: 4px;
    }
  }
}

// 功能激活，
.active {
  color: #6973ff;
}
// 选项激活
.item-active {
  background-color: rgba(103, 113, 252, 0.2);
  color: #6771fc;
  position: relative;

  &::before {
    background-color: #6973ff;
    border-radius: 50%;
    content: '';
    height: 4px;
    left: 6px;
    position: absolute;
    top: 10px;
    width: 4px;
  }
}
</style>

<style lang="less">
.switch-box-lasso-select {
  width: 108px;

  .ant-popover-content {
    .ant-popover-inner {
      width: 108px;

      .ant-popover-inner-content {
        padding: 4px 0;
        width: 108px;
      }
    }
  }
}
</style>
